package java_0629;

public class ThreadDemo14 {
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(){
            @Override
            public void run() {
                while(!Thread.currentThread().isInterrupted()){
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                        break;
                    }
                }
            }
        };
        System.out.println(t.getId()+":"+t.getState());
        t.start();
        Thread.sleep(1000);
        System.out.println(t.getId()+":"+t.getState());
        Thread.sleep(3000);
        t.interrupt();
        Thread.sleep(1000);
        System.out.println(t.getId()+":"+t.getState());

    }
}
